package com.chuanjiabao.wisdom.util.dialog;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;

import com.chuanjiabao.wisdom.R;
import com.chuanjiabao.wisdom.databinding.DialogTakeInheritBinding;
import com.chuanjiabao.wisdom.listener.OnBHClickListener;
import com.chuanjiabao.wisdom.listener.OnShareStypeClickListener;
import com.chuanjiabao.wisdom.util.GlideUtil;
import com.chuanjiabao.wisdom.util.ToastUtil;
import com.flyco.animation.SlideEnter.SlideTopEnter;
import com.flyco.animation.SlideExit.SlideBottomExit;
import com.flyco.dialog.widget.base.BaseDialog;

public class TakeInheritDialog extends BaseDialog {

    private Context context;
    private String name, img;
    private DialogTakeInheritBinding binding;
    private OnShareStypeClickListener listener;

    public TakeInheritDialog(Context context, String name, String img) {
        super(context, true);
        this.context = context;
        this.name = name;
        this.img = img;
    }

    @Override
    public View onCreateView() {
        widthScale(0.75f);
        binding = DataBindingUtil.inflate(
                LayoutInflater.from(context),
                R.layout.dialog_take_inherit,
                null,
                false
        );
        binding.setDialog(this);
        return binding.getRoot();
    }

    @Override
    public void setUiBeforShow() {
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        showAnim(new SlideTopEnter());
        dismissAnim(new SlideBottomExit());

        binding.tvDialogName.setText(name);
        GlideUtil.setCircleMethod(context, img, binding.ivModuleImg);
    }

    public void setOnBHClickListener(OnShareStypeClickListener listener) {
        this.listener = listener;
    }

    public void okPoint(View view) {
        if (listener != null) {
            String code = binding.etModuleCode.getText().toString();
            if (TextUtils.isEmpty(code)) {
                ToastUtil.showToast("请输入传承码");
                return;
            }
            listener.setOnShareStyleClickListener(binding.etModuleCode.getText().toString());
        }
        dismiss();
    }

    public void noPoint(View view) { dismiss(); }

}


